<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	  xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<!--	<base href="/">-->
	<link rel="stylesheet"  th:href="@{/bootstrap/css/bootstrap.min.css}">
	<link rel="stylesheet"  th:href="@{/css/update.css}"/>
	<link rel="stylesheet"  th:href="@{/css/bootstrap-datetimepicker.min.css}"/>
	<link rel="stylesheet"  th:href="@{/assets/layui.css}">
	<link rel="stylesheet"  th:href="@{/assets/view.css}"/>
</head>
<body>
<div th:replace="common/commoncss :: commoncss"></div>
<div th:fragment="informtable">

<div class="bgc-w box box-primary">
	<!--盒子头-->
	<div class="box-header">
		<h3 class="box-title">
			<a th:href="@{/notice/edit}" target="content" class="label label-success" style="padding: 5px;">
				<span class="glyphicon glyphicon-plus"></span>
				新增
			</a>
			<a href="" class="label label-success" style="padding: 5px;margin-left:5px;">
				<span class="glyphicon glyphicon-refresh"></span> 刷新
			</a>
		</h3>
		<form th:action="@{/notice/manage}" method="post">
			<div class="input-group" style="width:150px;float:right;top:-25px">
				<input type="text" class="form-control input-sm pull-right baseKey" name="title" th:value="${title}" placeholder="按标题查找" />
				<div class="input-group-btn" style="top:-1px;">
	<!--				<a class="btn btn-sm btn-default glyphicon glyphicon-search btn-change baseKetsubmit"></a>-->
					<input type="submit" class="btn btn-sm btn-default glyphicon glyphicon-search btn-change baseKetsubmit" value="查询">
				</div>
			</div>
		</form>
	</div>
	<!--盒子身体-->
	<div class="box-body no-padding">
		<div class="table-responsive">
			<table class="table table-hover">
				<tr>
					<th scope="col"><span class="paixu thistype">类型
						<span class="glyphicon ${icon}"></span>
						</span></th>
					<th scope="col"><span class="paixu thisstatus">状态
							<span class="glyphicon ${icon}"></span>
						</span></th>
					<th scope="col">标题</th>
					<th scope="col"><span class="paixu thistime">发布时间
							<span class="glyphicon ${icon}"></span>
						</span></th>
					<th scope="col">发布人</th>
					<th scope="col">部门</th>
					<th scope="col">置顶</th>
					<th scope="col">链接</th>
					<th scope="col">操作</th>
				</tr>

				<tr th:each="notice:${noticeLists}">
					<td><span th:text="${#typeDict.getTypeName('inform',notice.type)}"></span></td>
					<td><span class="label" th:classappend="${#statusDict.getStatusColor('inform',notice.status)}" th:text="${#statusDict.getStatusName('inform',notice.status)}"></span></td>
					<td><span th:text="${notice.title}"></span></td>
					<td><span th:text="${#dates.format(notice.noticeTime,'yyyy-MM-dd HH:mm:ss')}"></span></td>
					<td><span th:text="${notice.aoaUser.userName}"></span></td>
					<td><span th:text="${notice.aoaDept.deptName}"></span></td>

					<td th:if="${notice.isTop == 1}"><span class="labels">
						<label>
							<input type="checkbox" checked disabled>
							<i>✓</i>
						</label>
					</span></td>
					<td th:if="${notice.isTop == 0}"><span class="labels">
						<label>
						<input type="checkbox" disabled><i>✓</i>
						</label></span>
					</td>
					<td><span th:if="${notice.url != ''}" class="glyphicon glyphicon-link"></span></td>
					<td><span class="labels"></span></td>
					<td>
						<a th:href="@{/notice/edit(noticeId=${notice.noticeId})}" class="label xiugai">
							<span class="glyphicon glyphicon-edit"></span>修改
						</a>
						<a th:href="@{/notice/show(noticeId=${notice.noticeId})}" class="label xiugai ">
							<span class="glyphicon glyphicon-search"></span>查看
						</a>
						<a th:onclick="|deleteNotice(${notice.noticeId})|" class="label shanchu">
							<span class="glyphicon glyphicon-remove" ></span> 删除
						</a>
<!--						<a th:onclick="{return confirm('删除该记录将不能恢复，确定删除吗？');};" class="label shanchu" th:href="@{/notice/delete(noticeId=${notice.noticeId})}">-->
<!--							<span class="glyphicon glyphicon-remove" ></span> 删除-->
<!--						</a>-->
					</td> 
				</tr>
			</table>
		</div>
	</div>
	<!--分页导航-->
	<div class="container">
		<div class="row text-center">
			<div class="col-md-12">
				<ul class="pagination">
					<li><a th:class="${currentPage eq 1 ? 'btn disabled' : ''}" href="javascript:;" th:href="@{/notice/manage(page=1)}">首页</a></li>
					<li><a th:class="${currentPage eq 1 ? 'btn disabled' : ''}" href="javascript:;" th:href="@{/notice/manage(page=${currentPage}-1)}">上一页</a></li>
					<li th:class="${page eq currentPage} ? 'active' : ''" th:each="page:${#numbers.sequence(1,totalPage)}">
						<a href="javascript:;" th:href="@{/notice/manage(page=${page})}" th:text="${page}">1</a>
					</li>
					<li><a th:class="${currentPage eq totalPage ? 'btn disabled' : ''}" href="javascript:;" th:href="@{/notice/manage(page=${currentPage}+1)}">下一页</a></li>
					<li><a th:class="${currentPage eq totalPage ? 'btn disabled' : ''}" href="javascript:;" th:href="@{/notice/manage(page=${totalPage})}">尾页</a></li>
					<li><a style="border: 0px;margin-left: 0px;">当前页<span th:text="${currentPage}"></span>/<span th:text="${totalPage}"></span>总页</a></li>
				</ul>
			</div>
		</div>
	</div>
</div>
<script src="../assets/layui.all.js" th:src="@{/assets/layui.all.js}"></script>
<script type="text/javascript" th:src="@{/easyui/jquery.min.js}"></script>

<script th:inline="javascript">
	//获取应用路径
	var contextPath = [[${#request.getContextPath()}]];
</script>
<script>
	layui.use(['laypage', 'layer'], function() {
		var laypage = layui.laypage
				, layer = layui.layer;

	})

	//删除公告
	function deleteNotice(noticeId) {

		//询问框
		layer.confirm('确认删除吗？', {
			btn: ['必须的','算了吧'] //按钮
		}, function(){
			//异步修改用户的状态
			$.ajax({
				url : contextPath + "/notice/delete",
				data : {"noticeId" : noticeId},
				method : "post",
				success : function (data) {
					layer.msg(data.message,{icon:1, time:1000},function () {
						//自动刷新当前页面
						window.location.reload(true);
					});
				}
			})
		}, function(){
			layer.msg('取消成功', {
				time: 1000, //20s后自动关闭
			});
		});
	}
</script>
</div>
</body>

</html>